rem Compile program

set BIN_NAME=%MLC_BIN_NAME%
IF NOT DEFINED MLC_BIN_NAME SET BIN_NAME=run.exe

set RUN_DIR=%MLC_RUN_DIR%
IF NOT DEFINED MLC_RUN_DIR SET RUN_DIR=.

echo.
echo Checking compiler version ...
echo.

"%MLC_C_COMPILER_WITH_PATH%" %MLC_C_COMPILER_FLAG_VERSION%

echo.
echo Compiling source files ...
echo.

if not exist "%RUN_DIR%" mkdir "%RUN_DIR%"

cd "%MLC_SOURCE_FOLDER_PATH%"
IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%

if not "%MLC_C_SOURCE_FILES%" == "" (
  echo %MLC_C_COMPILER_WITH_PATH% %MLC_C_COMPILER_FLAGS% %MLC_C_INCLUDE_PATH% %MLC_C_SOURCE_FILES% %MLC_LD_LIBRARY_PATH% %LDCFLAGS% %MLC_C_COMPILER_FLAG_OUTPUT%"%RUN_DIR%\%BIN_NAME%"
  "%MLC_C_COMPILER_WITH_PATH%" %MLC_C_COMPILER_FLAGS% "%MLC_C_INCLUDE_PATH%" %MLC_C_SOURCE_FILES% "%MLC_LD_LIBRARY_PATH%" %LDCFLAGS% %MLC_C_COMPILER_FLAG_OUTPUT%"%RUN_DIR%\%BIN_NAME%"
  IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%
)

if not "%MLC_CXX_SOURCE_FILES%" == "" (
  echo %MLC_CXX_COMPILER_WITH_PATH%  %MLC_CXX_SOURCE_FILES% %MLC_CXX_COMPILER_FLAGS% %MLC_CPLUS_INCLUDE_PATH% %MLC_LD_LIBRARY_PATH% %LDCXXFLAGS% %MLC_CXX_COMPILER_FLAG_OUTPUT%"%RUN_DIR%\%BIN_NAME%"
  "%MLC_CXX_COMPILER_WITH_PATH%"  %MLC_CXX_SOURCE_FILES% %MLC_CXX_COMPILER_FLAGS% "%MLC_CPLUS_INCLUDE_PATH%" "%MLC_LD_LIBRARY_PATH%" %LDCXXFLAGS% %MLC_CXX_COMPILER_FLAG_OUTPUT%"%RUN_DIR%\%BIN_NAME%"
  IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%
)

